//============================================================================
/**
 *
 *	@file		catch_define.h
 *	@brief		UFOキャッチ 汎用定数
 *	@author		hosaka genya
 *	@data		2008.12.01
 *
 */
//============================================================================
#pragma once

#include "pkthev_catch.naix"
#include "catch_obj_main_NANR_LBLDEFS.h"
#include "catch_obj_sub_NANR_LBLDEFS.h"
#include "catch_obj_cmn_NANR_LBLDEFS.h"
#include "catch_pbj_pri.h"

//=============================================================================
/**
 *								調整用定数
 */
//=============================================================================
static const fx32 POKE_PUSH_VEC_MAX_FX = FX32_CONST(8.0F);	///< ふっとび速度の上限
static const fx32 POKE_PUSH_DEC_FX = FX32_CONST(0.8F);		///< 毎フレーム踏ん張る力
static const f32 UFO_DEF_SCALE_F = 1.2F;					///< UFOのデフォルト拡大率
static const f32 POKE_DEF_SCALE_F = 1.0F;

enum
{
	RING_X_MIN = 8,
	RING_Y_MIN = 8,
	RING_X_MAX = 31 * 8,
	RING_Y_MAX = 23 * 8 - 4,

	POKE_TOUCH_PLAY = 8,		///< タッチ判定のアソビ(ドット)
	POKE_FALL_TIMER = 30 * 3,	///< 落下タイマー
	POKE_HOLD_POWER_DIV = 5,	///< タッチふんばり時のパワーを割る分母

	// --- JUMP ---
	JUMP_CHECK_SYNC = 5,				///< このSYNC内にペンを放すとジャンプする
	JUMP_Z_CLAMP_FX = -FX32_CONST(24),	///< ジャンプ最大値

	// --- UFO ---
	UFO_ID_MAX = 2,				///< UFOの最大数(通信データと密着)
	UFO_DIFF_SHADOW = -40,		///< UFOと影の差異(影基準)
	UFO_DISPOUT_DISTANCE = 48,	///< 画面アウト演出中の距離
	UFO_HIT_CIRCLE = 14,		///< UFOとの当たり判定(UFO半径)
	UFO_SCORE_SYNC = 20,		///< スコアを表示する時間

	// --- AI ---
	AI_ACTION_SPAN = 20,		///< 抽選フレーム
	AI_POS_RAND_SPAN = 30 * 3,	///< ポジション抽選フレーム
	AI_UFO_RANGE_JUMP = 16,		///< ジャンプ用 UFO探索範囲
	AI_UFO_RANGE_SEARCH = 56,	///< 移動用 UFO探索範囲
	AI_JUMP_AVERAGE_ADD = 20,	///< 平均＋この値より自分のスコアが大きければジャンプしない

	// --- 競技 ---
	GAME_TIME = 30 * 60,		///< プレイ時間(SYNC)

	// --- BG Trans Anime ---
	BG_TRANS_ANIME_SYNC = 4,
	BG_TRANS_ANIME_NUM = 6,
	BG_TRANS_ANIME_X = 4,
	BG_TRANS_ANIME_Y = 4,
	BG_TRANS_ANIME_SIZE = BG_TRANS_ANIME_X * BG_TRANS_ANIME_Y,
};


//--------------------------------------------------------------
///	二点座標
//==============================================================
typedef struct POS_DATA_tag
{
	s16 X;
	s16 Y;
} POS_DATA;

//--------------------------------------------------------------
///	初期配置テーブル
//==============================================================
static const POS_DATA g_PokeInitPos[ENTRY_MEMBER_NUM_MAX][ENTRY_MAX] = {
	{ { 40, 40},{ 40, 88},{ 40, 152} },
	{ { 96, 40},{ 96, 88},{ 96, 152} },
	{ {160, 40},{160, 88},{160, 152} },
	{ {216, 40},{216, 88},{216, 152} },
};

//--------------------------------------------------------------
///	UFOのレベルを変更する時間 (〜以下)
//==============================================================
#define UFO_LEVEL_MAX (4)
static const g_UFO_LevelChangeSync[ UFO_LEVEL_MAX ] = {
	55, 40, 20, 0,
};

//=============================================================================
/**
 *								構造体
 */
//=============================================================================

//--------------------------------------------------------------
///	UFOキャッチ用タッチ情報
//==============================================================
typedef struct TP_STATE_CATCH_tag
{
	u32 ContCounter : 14;
	u32 Trg : 1;
	u32 Cont : 1;
	//[ADD]
	u32 ReleaseCount : 13;
	u32 bLockOn : 1;
	u32 PokeIdx : 2;
} TP_STATE_CATCH;

//--------------------------------------------------------------
///	UFOのデータ
//==============================================================
typedef struct UFO_DATA_tag {
	s16 PosX;
	s16 PosY;
	u32 GetPlayerID : 2;	///< UFOの座標
	u32 State : 3;			///< 状態8パターン
	u32 bAlive : 1;			///< 生存フラグ
	u32 ScoreTimer : 8;		///< スコアタイマー
	u32 DummyBit : 18;
	u8 ID;					///< 管理ID
	u8 Vec;					///< UFOの進行方向
	u8 SpeedY;				///< 移動量
} UFO_DATA;


// UFO発見時に毎フレームジャンプする確率（列ごと）
static const int g_AIJumpParsent[] = { 3, 6, 36 };

//=============================================================================
/**
 *								システム定数
 */
//=============================================================================

//--------------------------------------------------------------
///	System Const
//==============================================================
enum
{
	CATCH_HEAP_SIZE = 0x60000,
	GAME_FPS = 30,
	DISP_DISTANCE = 96,
	DISP_RANGE_Y = 192 * 2 + DISP_DISTANCE,
	OBJ_DISTANCE = FX32_CONST(96*5),					///< システム上の画面差(回り込み阻止)
	ACT_POKE_MAX = ENTRY_MEMBER_NUM_MAX * ENTRY_MAX,	///< ポケモン数
	PLTT_OFS_SCORE = 14,								///< スコアのパレット位置（キメ打ち)
	PLTT_OFS_SMOKE = 14,
};

//--------------------------------------------------------------
///	CATS Resource Index
//==============================================================
enum {
	OBJ_ID_MAX = 128,		///< 画面に同時に出現するOBJの上限
	CAP_ALL_NUM = 128,		///< CAPで管理するOBJの上限
	CMN_RES_NUM = 2,		///< 共通リソースの数
	CATS_RES_TBL_OFS = 10000,

	CHR_ID_MAIN = CATS_RES_TBL_OFS,
	CHR_ID_SUB,
	CHR_ID_CMN_M,
	CHR_ID_CMN_S,
	CHR_ID_END,
	CHR_ID_MAX = CMN_RES_NUM + CHR_ID_END - CATS_RES_TBL_OFS,

	PAL_ID_MAIN = CATS_RES_TBL_OFS,
	PAL_ID_SUB,
	PAL_ID_CMN_M,
	PAL_ID_CMN_S,
	PAL_ID_END,
	PAL_ID_MAX = CMN_RES_NUM + PAL_ID_END - CATS_RES_TBL_OFS,

	CEL_ID_MAIN = CATS_RES_TBL_OFS,
	CEL_ID_SUB,
	CEL_ID_CMN,
	CEL_ID_END,
	CEL_ID_MAX = CMN_RES_NUM + CEL_ID_END - CATS_RES_TBL_OFS,

	ANM_ID_MAIN = CATS_RES_TBL_OFS,
	ANM_ID_SUB,
	ANM_ID_CMN,
	ANM_ID_END,
	ANM_ID_MAX = CMN_RES_NUM + ANM_ID_END - CATS_RES_TBL_OFS,
};

//--------------------------------------------------------------
///	BG用定数
//==============================================================
enum {
	BG_FRM_M_TRANS = GF_BGL_FRAME0_M,
	BG_FRM_M_LAND = GF_BGL_FRAME1_M,
	BG_FRM_M_RSLT = GF_BGL_FRAME2_M,
	BG_FRM_S_TRANS = GF_BGL_FRAME0_S,
	BG_FRM_S_WIN =  GF_BGL_FRAME1_S,
	BG_FRM_S_SCORE = GF_BGL_FRAME2_S,
	BG_FRM_S_TEXT = GF_BGL_FRAME3_S,

	BG_FRM_M_RSLT_MASK = GX_PLANEMASK_BG2,
	MAIN_FONT_PAL = 15,
	SUB_FONT_PAL = 15,
	SCR_DEF_OFS = 8,
};

#define BG_USE_NUM (7)
static const c_BG_UseList[ BG_USE_NUM ] =
{
	// LCD MAIN
	BG_FRM_M_TRANS,	///< 海
	BG_FRM_M_LAND,	///< 土台
	BG_FRM_M_RSLT,	///< リザルト
	// LCD SUB
	BG_FRM_S_TRANS,	///< 海
	BG_FRM_S_WIN,	///< 枠
	BG_FRM_S_SCORE,	///< 得点
	BG_FRM_S_TEXT,	///< テキスト
};

//---------------------------------------------
// Font Color
//---------------------------------------------
#define	COL_N_WHITE	( GF_PRINTCOLOR_MAKE( 15, 14, 0 ) )		// フォントカラー：白
